package com.hyt.it.ogt.ks.service.impl;

import com.hyt.core.base.BaseServiceImpl;
import com.hyt.it.ogt.ks.api.kw.model.CandidateLogDTO;
import com.hyt.it.ogt.ks.mapper.CandidateLogMapper;
import com.hyt.it.ogt.ks.model.entity.CandidateLog;
import com.hyt.it.ogt.ks.model.vo.CandidateLogBeginTimeVO;
import com.hyt.it.ogt.ks.service.ICandidateLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.util.List;

/**
 * <p>
 * 考生考试操作轨迹，包括作答日志、登录、提交答案、切换屏幕、复制粘贴等 服务实现类
 * </p>
 *
 * @author chengxh
 * @since 2020-06-17
 */
@Service
@Slf4j
public class CandidateLogServiceImpl extends BaseServiceImpl<CandidateLogMapper, CandidateLog> implements ICandidateLogService {
    @Override
    public List<CandidateLogDTO> getCandidateExamLogDetail(String candidateId) {
        return baseMapper.getCandidateExamLogDetail(candidateId);
    }
    
    @Override
    public void saveCandidateLog(CandidateLog candidateLog) {

    }

    @Override
    public void saveLog(String examId, String itemId, String candidateId, int type, String operateContent, HttpServletRequest request) {

    }

    @Override
    public void saveLog(String examId, String candidateId, int type, String operateContent, HttpServletRequest request){

    }

    @Override
    public void saveLog(String examId, String itemId, String candidateId, int type, HttpServletRequest request){

    }

    @Override
    public void printlnLog(String title, String ...s){
        StringBuffer sb = new StringBuffer();
        if(s.length > 0) {
            try {
                sb.append(InetAddress.getLocalHost().getHostAddress());
                sb.append("#");
            }catch (Exception e){}
            sb.append(Thread.currentThread().getName());
            for (String s1 : s) {
                sb.append("#【");
                sb.append(s1);
                sb.append("】");
            }
            log.info("{}：{}", title, sb.toString());
        }
    }

    @Override
    public List<CandidateLogBeginTimeVO> getCandidateLogBeginTime(String examId, String operatorType) {
        List<CandidateLogBeginTimeVO> candidateLogBeginTimeList = baseMapper.getCandidateLogBeginTime(examId, operatorType);
        return candidateLogBeginTimeList;
    }
}
